package com.qfedu.sca.controller;

import com.qfedu.sca.common.param.UserAdd;
import com.qfedu.sca.common.param.UserLogin;
import com.qfedu.sca.common.vo.R;
import com.qfedu.sca.entity.User;
import com.qfedu.sca.service.UserService;
import lombok.Data;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 千锋Java,为你而生！
 *
 * @Author: Feri
 * @Date:2024/11/8 10:10
 * @Modified:
 */
@RestController
@RequestMapping("server/user")
public class UserController {
    @Resource
    private UserService service;

    @PostMapping("add")
    public R add(@RequestBody UserAdd user){
        return service.add(user);
    }

    @GetMapping("all")
    public R all(String name){
        return service.queryAll(name);
    }

    @PostMapping("login")
    public R login(@RequestBody UserLogin user){
        return service.login(user);
    }

    @GetMapping("logout")
    public R logout(HttpServletRequest request){

        return service.logout(request.getHeader("scatoken"));
    }

}
